home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung CD 2 (Tewi)(1994).iso / c / compiler / cpp / cpp.h < prev    next >
C/C++ Source or Header  |  1985-11-27  |  10KB  |  248 lines

  1.  
  2.  
  3. /*
  4.  *      I n t e r n a l   D e f i n i t i o n s    f o r   C P P
  5.  *
  6.  * In general, definitions in this file should not be changed.
  7.  */
  8.  
  9. #ifndef TRUE
  10. #define TRUE            1
  11. #define FALSE           0
  12. #endif
  13. #ifndef EOS
  14. /*
  15.  * This is predefined in Decus C
  16.  */
  17. #define EOS             '\0'            /* End of string                */
  18. #endif
  19. #define EOF_CHAR        0               /* Returned by get() on eof     */
  20. #define NULLST          ((char *) NULL) /* Pointer to nowhere (linted)  */
  21. #define DEF_NOARGS      (-1)            /* #define foo vs #define foo() */
  22.  
  23. /*
  24.  * The following may need to change if the host system doesn't use ASCII.
  25.  */
  26. #define ST_QUOTE        0x1C            /* Magic for stringizing        */
  27. #define DEF_MAGIC       0x1D            /* Magic for #defines           */
  28. #define TOK_SEP         0x1E            /* Token concatenation delim.   */
  29. #define COM_SEP         0x1F            /* Magic comment separator      */
  30. #define MAC_PARM        0x7F            /* Macro formals signal         */
  31.  
  32. /*
  33.  * Character type codes.
  34.  */
  35.  
  36. #define INV             0               /* Invalid, must be zero        */
  37. #define OP_EOE          INV             /* End of expression            */
  38. #define DIG             1               /* Digit                        */
  39. #define LET             2               /* Identifier start             */
  40. #define FIRST_BINOP     OP_ADD
  41. #define OP_ADD          3
  42. #define OP_SUB          4
  43. #define OP_MUL          5
  44. #define OP_DIV          6
  45. #define OP_MOD          7
  46. #define OP_ASL          8
  47. #define OP_ASR          9
  48. #define OP_AND          10              /* &, not &&                    */
  49. #define OP_OR           11              /* |, not ||                    */
  50. #define OP_XOR          12
  51. #define OP_EQ           13
  52. #define OP_NE           14
  53. #define OP_LT           15
  54. #define OP_LE           16
  55. #define OP_GE           17
  56. #define OP_GT           18
  57. #define OP_ANA          19              /* &&                           */
  58. #define OP_ORO          20              /* ||                           */
  59. #define OP_QUE          21              /* ?                            */
  60. #define OP_COL          22              /* :                            */
  61. #define OP_CMA          23              /* , (relevant?)                */
  62. #define LAST_BINOP      OP_CMA          /* Last binary operand          */
  63. /*
  64.  * The following are unary.
  65.  */
  66. #define FIRST_UNOP      OP_PLU          /* First Unary operand          */
  67. #define OP_PLU          24              /* + (draft ANSI standard)      */
  68. #define OP_NEG          25              /* -                            */
  69. #define OP_COM          26              /* ~                            */
  70. #define OP_NOT          27              /* !                            */
  71. #define LAST_UNOP       OP_NOT
  72. #define OP_LPA          28              /* (                            */
  73. #define OP_RPA          29              /* )                            */
  74. #define OP_END          30              /* End of expression marker     */
  75. #define OP_MAX          (OP_END + 1)    /* Number of operators          */
  76. #define OP_FAIL         (OP_END + 1)    /* For error returns            */
  77.  
  78. /*
  79.  * The following are for lexical scanning only.
  80.  */
  81.  
  82. #define QUO             65              /* Both flavors of quotation    */
  83. #define DOT             66              /* . might start a number       */
  84. #define SPA             67              /* Space and tab                */
  85. #define BSH             68              /* Just a backslash             */
  86. #define END             69              /* EOF                          */
  87.  
  88. /*
  89.  * These bits are set in ifstack[]
  90.  */
  91. #define WAS_COMPILING   1               /* TRUE if compile set at entry */
  92. #define ELSE_SEEN       2               /* TRUE when #else processed    */
  93. #define TRUE_SEEN       4               /* TRUE when #if TRUE processed */
  94.  
  95. /*
  96.  * Define bits for the basic types and their adjectives
  97.  */
  98.  
  99. #define T_CHAR            1
  100. #define T_INT             2
  101. #define T_FLOAT           4
  102. #define T_DOUBLE          8
  103. #define T_SHORT          16
  104. #define T_LONG           32
  105. #define T_SIGNED         64
  106. #define T_UNSIGNED      128
  107. #define T_PTR           256             /* Pointer                      */
  108. #define T_FPTR          512             /* Pointer to functions         */
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. /*
  124.  * The DEFBUF structure stores information about #defined
  125.  * macros.  Note that the defbuf->repl information is always
  126.  * in malloc storage.
  127.  */
  128.  
  129. typedef struct defbuf {
  130.         struct defbuf   *link;          /* Next define in chain */
  131.         char            *repl;          /* -> replacement       */
  132.         int             hash;           /* Symbol table hash    */
  133.         int             nargs;          /* For define(args)     */
  134.         char            name[1];        /* #define name         */
  135. } DEFBUF;
  136.  
  137. /*
  138.  * The FILEINFO structure stores information about open files
  139.  * and macros being expanded.
  140.  */
  141.  
  142. typedef struct fileinfo {
  143.         char            *bptr;          /* Buffer pointer       */
  144.         int             line;           /* for include or macro */
  145.         FILE            *fp;            /* File if non-null     */
  146.         struct fileinfo *parent;        /* Link to includer     */
  147.         char            *filename;      /* File/macro name      */
  148.         char            *progname;      /* From #line statement */
  149.         unsigned int    unrecur;        /* For macro recursion  */
  150.         char            buffer[1];      /* current input line   */
  151. } FILEINFO;
  152.  
  153. /*
  154.  * The SIZES structure is used to store the values for #if sizeof
  155.  */
  156.  
  157. typedef struct sizes {
  158.     short       bits;                   /* If this bit is set,          */
  159.     short       size;                   /* this is the datum size value */
  160.     short       psize;                  /* this is the pointer size     */
  161. } SIZES;
  162. /*
  163.  * nomacarg is a built-in #define on Decus C.
  164.  */
  165.  
  166. #ifdef  nomacarg
  167. #define cput            output          /* cput concatenates tokens     */
  168. #else
  169. #if COMMENT_INVISIBLE || OK_CONCAT == CON_EXPAND
  170. #define cput(c)         { if ((c) != TOK_SEP && (c) != COM_SEP) \
  171.                             putchar((c == ST_QUOTE) ? '"' : (c)); }
  172. #else
  173. #define cput(c)         { if (c != TOK_SEP) \
  174.                             putchar((c == ST_QUOTE) ? '"' : (c)); }
  175. #endif
  176. #endif
  177.  
  178. #ifndef nomacarg
  179. #define streq(s1, s2)   (strcmp(s1, s2) == 0)
  180. #endif
  181.  
  182. /*
  183.  * Error codes.  VMS uses system definitions.
  184.  * Decus C codes are defined in stdio.h.
  185.  * Others are cooked to order.
  186.  */
  187.  
  188. #if HOST == SYS_VMS
  189. #include                <ssdef.h>
  190. #include                <stsdef.h>
  191. #define IO_SUCCESS      (SS$_NORMAL | STS$M_INHIB_MSG)
  192. #define IO_ERROR        SS$_ABORT
  193. #endif
  194. /*
  195.  * Note: IO_SUCCESS and IO_ERROR are defined in the Decus C stdio.h file
  196.  */
  197. #ifndef IO_SUCCESS
  198. #define IO_SUCCESS      0
  199. #endif
  200. #ifndef IO_ERROR
  201. #define IO_ERROR        1
  202. #endif
  203.  
  204. /*
  205.  * Externs
  206.  */
  207.  
  208. extern int      line;                   /* Current line number          */
  209. extern int      wrongline;              /* Force #line to cc pass 1     */
  210. extern char     type[];                 /* Character classifier         */
  211. extern char     token[IDMAX + 1];       /* Current input token          */
  212. extern int      instring;               /* TRUE if scanning string      */
  213. extern int      inmacro;                /* TRUE if scanning #define     */
  214. extern int      errors;                 /* Error counter                */
  215. extern int      recursion;              /* Macro depth counter          */
  216. extern char     ifstack[BLK_NEST];      /* #if information              */
  217. #define compiling ifstack[0]
  218. extern char     *ifptr;                 /* -> current ifstack item      */
  219. extern char     *incdir[NINCLUDE];      /* -i directories               */
  220. extern char     **incend;               /* -> active end of incdir      */
  221. extern int      cflag;                  /* -C option (keep comments)    */
  222. extern int      eflag;                  /* -E option (ignore errors)    */
  223. extern int      nflag;                  /* -N option (no pre-defines)   */
  224. extern int      pflag;                  /* -P option (no #line output)  */
  225. extern int      tflag;                  /* -T option (enable trigraphs) */
  226. extern int      rec_recover;            /* unwind recursive macros      */
  227. extern char     *preset[];              /* Standard predefined symbols  */
  228. extern char     *magic[];               /* Magic predefined symbols     */
  229. extern FILEINFO *infile;                /* Current input file           */
  230. extern char     work[NWORK + 1];        /* #define scratch              */
  231. extern char     *workp;                 /* Free space in work           */
  232. #if     DEBUG
  233. extern int      debug;                  /* Debug level                  */
  234. #endif
  235. extern int      keepcomments;           /* Don't remove comments if set */
  236. extern SIZES    size_table[];           /* For #if sizeof sizes         */
  237. extern char     *getmem();              /* Get memory or die.           */
  238. extern DEFBUF   *lookid();              /* Look for a #define'd thing   */
  239. extern DEFBUF   *defendel();            /* Symbol table enter/delete    */
  240. extern char     *savestring();          /* Stuff string in malloc mem.  */
  241. extern char     *strcpy();
  242. extern char     *strcat();
  243. extern char     *strrchr();
  244. extern char     *strchr();
  245. extern long     time();
  246. extern char     *sprintf();             /* Lint needs this              */
  247.  
  248.